package ar.edu.unq.wannaplay.utils.buttons;

import java.util.List;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.form.Form;

import ar.edu.unq.wannaplay.dtos.SkillDTO;
import ar.edu.unq.wannaplay.panels.AbstractEditModelObjectSkillsPanel;

public class RemoveItemAjaxButton extends ActionOnListAjaxButton {

    private static final long serialVersionUID = 1L;

    public RemoveItemAjaxButton(final String id,
            final AbstractEditModelObjectSkillsPanel<?, ?> abstractEditModelObjectSkillsPanel) {
        super(id, abstractEditModelObjectSkillsPanel);

    }

    @Override
    protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
        List<SkillDTO> modelList = this.getPanel().getSkillsList();
        modelList.removeAll(this.getPanel().getCurrentSkills());
        target.addComponent(this.getPanel().getChoicesList());
    }
}
